<%--
  Created by IntelliJ IDEA.
  User: User
  Date: 2023/12/22
  Time: 10:39
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page language="java" pageEncoding="UTF-8" %>
<%@page import="cn.estore.dao.CustomerDao" %>
<%
    out.clear();//清空当前的输出内容
    request.setCharacterEncoding("UTF-8");
    String name=request.getParameter("name");
    if ((name!=null)&&(name.equals("userName"))){
        name="user_name";
    }
    String value=request.getParameter("value");
    String info=null;
    //如果判断验证码,采用Session方式验证
    if ("code".equals(name)){
        //获取Session中保存的验证码
        String sessionCode=(String) session.getAttribute("_CODE_");
        //根据对比结果响出信息
        if (value!=null&&value.equals(sessionCode)){
            out.print("1验证码正确!");
        }else {
            out.print("0验证码错误");
        }
    }else {
        //根据name变量确认提示对象名称
        if ("user_name".equals(name)){
            info="用户名";
        }else if ("email".equals(name)){
            info="邮箱地址";
        }else if ("mobile".equals(name)){
            info="手机号码";
        }
        //根据是否存在相同信息输出响应
        CustomerDao eDao=new CustomerDao();
        if (eDao.hasSameValue(name,value)){
            out.print("0该"+info+"已存在");
        }else {
            out.print("1该"+info+"可用");
        }
    }
%>
<html>
<head>
    <title>Title</title>
</head>
<body>

</body>
</html>
